<?php
$yhendus=new mysqli("localhost", "if13", "ifikad", "if13_kaarmaha");
if(isSet($_REQUEST["uuspeoline"])){
$kask=$yhendus->prepare("INSERT INTO peolised (eesnimi, perenimi, epost) VALUES (?, ?, ?)");
$kask->bind_param("sss", $_REQUEST["eesnimi"], $_REQUEST["perenimi"], $_REQUEST["epost"]);
$kask->execute();
header("Location: $_SERVER[PHP_SELF]");
$yhendus->close();
exit();
}
if(isSet($_REQUEST["kustutusid"])){
$kask=$yhendus->prepare("DELETE FROM peolised WHERE id=?");
$kask->bind_param("i", $_REQUEST["kustutusid"]);
$kask->execute();
}
?>
<!doctype html>
<html>
<head>
<title>Registreerunud lehel</title>
<style type="text/css">
#menyykiht{
float: left;
padding-right: 30px;
}
#sisukiht{
float:left;
}
#jalusekiht{
clear: left;
}
</style>
<link rel="stylesheet" href="kujundus.css">
</head>
<body>
<div id="menyykiht">
<ul>
<li><a href="Kuulutus.php">Kuulutusleht</a></li>
<li><a href="Registreerimine.php">Registreerimisleht</a></li>
<li><a href="Etteasted.php">Etteasted</a></li>
<li><a href="Admin2.php">Etteastmete admin</a></li>
</ul>
<div id="peolised">
<h2>Peolised</h2>
<ul>
<?php
$kask=$yhendus->prepare("SELECT id, eesnimi FROM peolised");
$kask->bind_result($id, $eesnimi);
$kask->execute();
while($kask->fetch()){
echo "<li><a href='?id=$id'>".
htmlspecialchars($eesnimi)."</a></li>";
}
?>
</ul>
</div>
<a href='?lisamine=jah' class="lisa">Lisa ...</a>
</div>
<div id="sisukiht">
<?php
if(isSet($_REQUEST["id"])){
$kask=$yhendus->prepare("SELECT id, eesnimi, perenimi, epost FROM peolised
WHERE id=?");
$kask->bind_param("i", $_REQUEST["id"]);
$kask->bind_result($id, $eesnimi, $perenimi, $epost);
$kask->execute();
if($kask->fetch()){
echo "<h2>".htmlspecialchars($eesnimi)."</h2>";
echo "<p>".htmlspecialchars($perenimi);
echo '<br />';
echo htmlspecialchars($epost)."</p>";
echo "<br /><a href='?kustutusid=$id'>kustuta</a>";
} else {
echo "Vigased andmed.";
}
}
if(isSet($_REQUEST["lisamine"])){
?>
<form action='?'>
<input type="hidden" name="uuspeoline" value="jah" />
<h2>Uue peolise lisamine</h2>
<dl>
<dt>Eesnimi:</dt>
<dd>
<input type="text" name="eesnimi" />
</dd>
<dt>Perekonnanimi:</dt>
<dd>
<textarea rows="1" name="perenimi"></textarea>
</dd>
<dt>E-post:</dt>
<dd>
<textarea rows="10" name="epost"></textarea>
</dd>
</dl>
<input type="submit" value="sisesta">
</form>
<?php
}
?>
</div>
<div id="jalusekiht">
</div>
</body>
</html>
<?php
$yhendus->close();
?>

